<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>软件测试技术案例</title> 
<base href="<%=basePath%>"/>
<link rel="stylesheet" type="text/css" href="static/css/sm-default.css" />
<link rel="stylesheet" type="text/css" href="static/css/styles.css" />
<meta name="description" content="软件测试技术案例" />
<meta name="keywords" content="software testing, SpringMVC,Testing" />

<script type="text/javascript" src="static/js/jquery.min.js"></script>
<script type="text/javascript" src="static/js/json2.js"></script>
<script type="text/javascript"> 
function check(){  
	var areaAnswer = parseFloat(document.getElementById("areaAnswer").value);
	var perimeterAnswer = parseFloat(document.getElementById("perimeterAnswer").value);
	var judegAnswer = false;
	var obj = {}; 
	obj.areaAnswer = areaAnswer;
	obj.perimeterAnswer = perimeterAnswer;
	obj.judegAnswer = judegAnswer;
	var jsonanswer = JSON.stringify(obj); 
	alert(jsonanswer);
	$.ajax({
		type : 'POST',
		contentType : 'application/json',
		url : '<%=basePath%>/doquestion/check',
		data : jsonanswer,
		dataType : 'json',
		success : function(data) {
			if(data.code === 0)
			{
				alert(data.msg);
			}
			else
			{	
				$("div#msg").text("回答情况："+data.msg);
				$("div#rightAnswer").text("标准答案："+data.rightAnswer);
			} 
		}
	});
}   
</script>


</head>
<body>
 
		<h4>"${username}" 小朋友,请听题!</h4>
		<hr/> 
		<h3>${question}</h3>
		<h4>"${username}" 小朋友,请答题!</h4> 
	 
		<table class="loginTable" align="center">
			<tbody> 
				<tr>
					<td class="loginLabel" align="right">面积:</td>
					<td align="right"><input id="areaAnswer" type="text" /></td>
				</tr>
				<tr>
					<td class="loginLabel" align="right">周长:</td>
					<td align="right"><input id="perimeterAnswer" type="text" /></td>
				</tr>
				<tr>
					<td align="right">&nbsp;</td>
					<td align="right"><br /> 
					<button id="btn" onclick="check()">提交</button>
					</td> 
				</tr>
			</tbody>
		</table> 
		<div  style=" color: red;" id="msg"></div>
		<div  style=" color: red;" id="rightAnswer"></div>
	 
</body>
</html>
